<%@ page pageEncoding="UTF-8"%>
<%@ include file="../common/global.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <%@ include file="../common/meta.jsp"%>
    <title><f:message key="common.title" /> - <f:message key="user.user_list" /> </title>
    <%@ include file="../common/css.jsp"%>
    <link href="${BASE}/www/js/plugins/msgbox/jquery.msgbox.css" rel="stylesheet">
</head>
<body>
<div id="wrapper">
<%@ include file="../common/topbar.jsp"%>
<%@ include file="../common/header.jsp"%>

<div id="masthead">

    <div class="container">

        <div class="masthead-pad">
            <div class="masthead-pad">

                <div class="masthead-text">
                     <h5> 公众号管理</h5>
                </div> <!-- /.masthead-text -->

            </div>
        </div>

    </div> <!-- /.container -->

</div> <!-- /#masthead -->

    <div id="content">

        <div class="container">

            <div class="row">

                <span class="span9">
                        <div id="account_list">
                            <%@ include file="list.jsp"%>
                        </div>
                </span><!--/.span9 -->

                <div class="span3">
                    <div class="well">
                    <form id="account_search_form" class="navbar-form navbar-left" >
                        <div class="form-group">
                            <input name="account" type="text" class="form-control ext-required" >
                        </div>
                        <br/>
                        <div class="form-group">
                            <button type="submit" class="btn">
                                <f:message key="common.search" />
                            </button>
                            <button type="button" id="create" class="btn btn-primary">
                                添加公众号
                            </button>
                        </div>
                    </form>
                    </div>

                </div> <!-- /.span3 -->

            </div> <!-- /.row -->

        </div> <!-- /.container -->

    </div> <!-- /#content -->

</div> <!-- /#wrapper -->

<%@ include file="../common/footer.jsp"%>
<%@ include file="../common/js.jsp"%>
<script src="${BASE}/www/js/plugins/msgbox/jquery.msgbox.min.js"></script>


<script type="text/javascript">
    $(function() {
        $('#account_search_form').ajaxForm({
            type: 'post',
            url: BASE + '/accounts',
            dataType: 'html',
            success: function(html) {
                $('#account_list').html(html);
            }
        });

        $('.ext-user-delete').live ('click', function (e) {
            var $tr = $(this).closest('tr');
            var account = $tr.data('account');
            var url = $(this).attr('href');
            $.msgbox(Smart.i18n('删除账号', account), {
                type: "confirm",
                buttons : [
                    {type: "submit", value: "Yes"},
                    {type: "cancel", value: "Cancel"}
                ]
            }, function(result) {
                if (result!=false){
                    $.ajax({
                        type: 'delete',
                        url: url,
                        dataType: 'json',
                        success: function(result) {
                            if (result.success) {
                                location.reload();
                            }
                        }
                    });
                }
            });

            return false;

        });


        $('#create').click(function() {
            location.href = BASE + '/account';
        });

    });
</script>
</body>
</html>